package org.infodavid.common.util;

import java.lang.reflect.Method;

/**
 * The Class ReflectionUtil.
 */
public class ReflectionUtil {
	
	/**
	 * Gets the accessor method.
	 *
	 * @param clazz the clazz
	 * @param property the property
	 * @param obj the object
	 * @return the accessor method
	 */
	public static Object getAccessorMethod(Class<?> clazz, String property, Object obj) {
		Object result = null;
		try
		{
			StringBuilder builder = new StringBuilder("get");
			builder.append(Character.toUpperCase(property.charAt(0)));
			builder.append(property.substring(1));
			String methodNameFull = builder.toString();
			Method objGetter = clazz.getMethod(methodNameFull, new Class[0]);
			if(objGetter != null)
			{
				result = objGetter.invoke(obj);
			}
		}
		catch (Exception e) {		
		}
		return result;
	}
}
